<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>NPanday - Quick Start Guide</title>
    <style type="text/css" media="all">
      @import url("../../css/maven-base.css");
      @import url("../../css/maven-theme.css");
      @import url("../../css/site.css");
    </style>
    <link rel="stylesheet" href="../../css/print.css" type="text/css" media="print" />
          </head>
  <body class="composite">
    <div id="banner">
                  <a href="" id="bannerLeft">
    
                                            <img src="../.././images/NPanday.png" alt="" />
    
            </a>
                        <a href="http://www.codeplex.com/" id="bannerRight">
    
                                            <img src="../.././images/logo-home.png" alt="" />
    
            </a>
            <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
            
  
    
            <div class="xleft">
          
                <a href="http://npanday.codeplex.com/" class="externalLink">NPanday Home</a>
                &gt;
      
                <a href="../../">NPanday 1.2</a>
                  </div>
            <div class="xright">      
  

  
    
            
  
    
             Last Published: 22 Jun 2010
              &nbsp;| Version: 1.2
            </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
            
  
    
                   <h5>General Info</h5>
            <ul>
              
    <li class="none">
                    <a href="../../index.html">NPanday Overview</a>
          </li>
              
    <li class="none">
                    <a href="../../release-notes.html">NPanday Release Notes</a>
          </li>
              
    <li class="none">
                    <a href="../../faqs.html">NPanday FAQs</a>
          </li>
              
    <li class="none">
                    <a href="../../faqs.html">NPanday Features</a>
          </li>
              
    <li class="none">
                    <a href="../../npanday.pdf">Documentation PDF</a>
          </li>
          </ul>
              <h5>User's Guide</h5>
            <ul>
              
    <li class="none">
                    <a href="../.././guide/index.html">Introduction</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/installation/index.html">Installation</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/vs/index.html">Visual Studio Add-in</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/maven/index.html">Maven Command Line</a>
          </li>
              
    <li class="none">
                    <a href="../.././guide/devinfra/index.html">Maven Development Infrastructure</a>
          </li>
              
    <li class="none">
                    <a href="../../plugins/index.html">NPanday Plugins</a>
          </li>
          </ul>
              <h5>Contributing</h5>
            <ul>
              
    <li class="none">
                    <a href="../.././developers/index.html">Developer's Guide</a>
          </li>
              
    <li class="none">
                    <a href="../.././issue-tracking.html">Issue Tracking</a>
          </li>
              
    <li class="none">
                    <a href="../.././mail-lists.html">Mailing Lists</a>
          </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
              
      
            
      
            
      
            
      
            
      
            
      
            
      
              
        <li class="collapsed">
                    <a href="../../project-info.html">Project Information</a>
                </li>
          </ul>
              <h5>Resources</h5>
            <ul>
              
    <li class="none">
                    <a href="http://maven.apache.org/" class="externalLink">Apache Maven</a>
          </li>
              
    <li class="none">
                    <a href="http://npanday.codeplex.com/" class="externalLink">NPanday on CodePlex</a>
          </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="../../images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
            
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>Quick Start Guide</h2>
<p>This section is provides a quick overview of the NPanday .NET Build Tool by creating a sample project. You must first have installed the Add-in according to the instructions in the <a href="../installation/index.html"> installation guide</a>.</p>
<div class="section"><h3>Starting the Add-in</h3>
<p>Start Visual Studio ensuring that your PATH is set correctly, as described in the installation guide.</p>
<p>Next, in Visual Studio start the NPanday Build System from Tools&gt;NPanday Build System. You will see NPanday starting in the Visual Studio Output pane.</p>
<p><i>Note:</i> After you start the NPanday Build System and it is running, it no longer appears as an option on the Tools menu (and reappears again when Visual Studio is stopped and started). Therefore, if you had previously started the NPanday Build System and it is still running, you do not need to start it again in this step.</p>
</div>
<div class="section"><h3>Creating a Project</h3>
<p>Creating a project for use with NPanday is the same as you would normally do so for any project within Visual Studio. In this case, we will create a class library.</p>
<ol type="1"><li>Got to File &gt; New &gt; Project...</li>
<li>Retain the default of a C# Class Library (if you are using a different language variant of the IDE that will also work)</li>
<li>In the <i>Name</i> field, type <tt>NPandayTestQS</tt></li>
<li>Keep the other options the same (using the same name for the Solution and creating a directory for the solution) and press OK.</li>
</ol>
<p>You now have a simple, standard, project. However, nothing has been generated for Maven to be able to build it, so for that we need to generate a <tt>pom.xml</tt> file.</p>
</div>
<div class="section"><h3>Generating the POM</h3>
<p>NPanday makes creating the POM file(s) easy. To do so, right click on the project solution (or any of the projects) in the Solution Explorer and select <i>Generate Solution's POM Information...</i>:</p>
<img src="../../images/vs/generate-pom.jpg" /><p>Next, you will see the following dialog:</p>
<img src="../../images/vs/import-dialog.jpg" /><p>We'll look at this in more detail shortly, but for now accept the default settings, and do likewise on the next dialog asking about test projects. Finally, NPanday will inform you that it has created two <tt>pom.xml</tt> files: one for the solution, and one for the class library project. These files won't appear in the Solution Explorer - NPanday keeps them hidden as they don't need to be modified directly. However, they should be checked into your source control system to ensure that they can be used by other developers and the shared build infrastructure. In the next section we will take a closer look at the POM files.</p>
<div class="section"><h4>About the POM file</h4>
<p>First, we need to understand what the <tt>pom.xml</tt> file is. This is the sole descriptor used by Maven to build an entire project. In some respects, it is similar to the <tt>.sln</tt> and <tt>.csproj</tt> (or <tt>.vbproj</tt>) files, however Maven uses a different approach - while these are 'scripts', the POM is 'declarative', indicating where parts of the project are located, and which Maven plugins are used to build the project, utilizing that project information. By being declarative in this fashion, many plugins can operate on the same information without having to reconfigure each specifically.</p>
<p>Let's look at POM for the solution first:</p>
<div class="source"><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
         xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;MyCompany.NPandayTestQS&lt;/groupId&gt;
  &lt;artifactId&gt;NPandayTestQS-parent&lt;/artifactId&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;name&gt;MyCompany.NPandayTestQS : NPandayTestQS-parent&lt;/name&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;modules&gt;
    &lt;module&gt;NPandayTestQS&lt;/module&gt;
  &lt;/modules&gt;
&lt;/project&gt;</pre>
</div>
<p>You will notice a few important elements here. First, there is the <i>Group ID</i> which is the value that you entered into the previous dialog. There is also an <i>Artifact ID</i> that is the name of the solution with 'parent' appended. Further down, there is a <i>Version</i> that is set to the default of <tt>1.0-SNAPSHOT</tt>. These 3 elements constitute the project <i>co-ordinate</i>, which is a unique identifier across all projects you can access to this particular project. This is the reason that the solution appends <tt>-parent</tt> to the end, to distinguish it from the child project with the same name.</p>
<p>Within the group/artifact ID combination, each project is then versioned to distinguish between different releases. The default is <tt>1.0-SNAPSHOT</tt>, which means &quot;in development towards the 1.0 release&quot;. Maven places special significance on the <tt>SNAPSHOT</tt> addition to a version, which means that the project is changing. When a version is set to a concrete one such as <tt>1.0</tt>, Maven considers it to always remain the same and changes to go under a new version (such as <tt>1.1-SNAPSHOT</tt>).</p>
<p>We will later use these co-ordinates to locate and utilize dependencies on other projects from within our own project, even if we don't have a copy locally.</p>
<p>We also see the <i>Modules</i> section that shows which subproject exist. This contains a reference to the class library's project directory - so let's now look at the POM for that:</p>
<div class="source"><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
         xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;&gt;
  &lt;parent&gt;
    &lt;artifactId&gt;NPandayTestQS-parent&lt;/artifactId&gt;
    &lt;groupId&gt;MyCompany.NPandayTestQS&lt;/groupId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;relativePath&gt;..\pom.xml&lt;/relativePath&gt;
  &lt;/parent&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;artifactId&gt;NPandayTestQS&lt;/artifactId&gt;
  &lt;packaging&gt;library&lt;/packaging&gt;
  &lt;name&gt;MyCompany.NPandayTestQS : NPandayTestQS&lt;/name&gt;
  &lt;build&gt;
    &lt;sourceDirectory&gt;./&lt;/sourceDirectory&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compile-plugin&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
        &lt;configuration&gt;
          &lt;frameworkVersion&gt;2.0.50727&lt;/frameworkVersion&gt;
          &lt;includeSources&gt;
            &lt;includeSource&gt;Class1.cs&lt;/includeSource&gt;
            &lt;includeSource&gt;Properties\AssemblyInfo.cs&lt;/includeSource&gt;
          &lt;/includeSources&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
</div>
<p>This project starts with the <i>Parent</i> definition, which points back to the project for the solution. This is used to inherit any shared settings among subprojects (though by default, there is nothing saved in the parent POM that will be shared).</p>
<p>Next we have the artifact ID for this project, which uses the library name. The group ID and version can be omitted, since by default they will use the same one as the parent project.</p>
<p>In this project, we have altered the <i>Packaging</i> element to be of type <tt>library</tt>. While the parent was a <tt>pom</tt>, indicating it didn't build anything additional, this type indicates that Maven and NPanday should include all the standard build steps for a .NET class library.</p>
<p>Along with this we now have a <i>Build</i> section. This contains two further elements - first, the <i>source directory</i>, that says the Visual Studio convention of storing source files in the project directory (and subdirectories) will be followed. Next is the <i>Plugins</i> section, which is where Maven is told to use NPanday to compile, and what framework and source code to use. For other project types, additional plugins may be added (see the <a href="../../plugins/index.html"> Plugins Reference</a> for more available plugins).</p>
<p>While it is not necessary to be able to create these POM files to be able to use NPanday, understanding how they work, and in particular the Maven co-ordinate system, will help to understand what NPanday is doing &quot;behind the scenes&quot; when you use some of its other functionality.</p>
</div>
</div>
<div class="section"><h3>Building the Project</h3>
<p>With this in place, we can now check that Maven is able to build the project. Right click on the solution or project and select <i>All NPanday Projects</i>, then <i>Build [compile]</i>.</p>
<img src="../../images/vs/build.png" /><p>In the Output Window (if the NPanday Execution Output view is selected from the dropdown), you will see something similar to the following:</p>
<div class="source"><pre>------------------------------------------------------------------
Executing Maven
Pom File: C:\...\Visual Studio 2008\Projects\NPandayTestQS\pom.xml
Goal: compile
Arguments: compile
NPanday Command: c:\...\apache-maven-2.2.1\bin\mvn.bat compile


------------------------------------------------------------------

[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   MyCompany.NPandayTestQS : NPandayTestQS-parent
[INFO]   MyCompany.NPandayTestQS : NPandayTestQS
[INFO] ------------------------------------------------------------------------
[INFO] Building MyCompany.NPandayTestQS : NPandayTestQS-parent
[INFO]    task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] No goals needed for project - skipping
[INFO] ------------------------------------------------------------------------
[INFO] Building MyCompany.NPandayTestQS : NPandayTestQS
[INFO]    task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [compile:initialize {execution: default-initialize}]
...
[INFO] [resolver:resolve {execution: default-resolve}]
...
[INFO] [NPanday.Plugin.Settings.JavaBinding:generate-settings {execution: default-generate-settings}]
[INFO] [compile:generate-assembly-info {execution: default-generate-assembly-info}]
...
[INFO] [compile:process-sources {execution: default-process-sources}]
...
[INFO] [compile:process-test-sources {execution: default-process-test-sources}]
...
[INFO] [resgen:copy-resources {execution: default-copy-resources}]
[INFO] [resgen:generate {execution: default-generate}]
[INFO] [resgen:generate-existing-resx-to-resource {execution: default-generate-existing-resx-to-resource}]
[INFO] [compile:compile {execution: default-compile}]
...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] MyCompany.NPandayTestQS : NPandayTestQS-parent ........ SUCCESS [0.005s]
[INFO] MyCompany.NPandayTestQS : NPandayTestQS ............... SUCCESS [10.547s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18 seconds
[INFO] Finished at: Wed Feb 03 12:58:47 EST 2010
[INFO] Final Memory: 12M/24M
[INFO] ------------------------------------------------------------------------
NPanday Execution is Successful!</pre>
</div>
<p>Here, both projects are built (since it was run from the solution level). The solution POM has no steps to perform to compile. However, you can see several steps (<tt>compile:initialize</tt>, <tt>resolver:resolve</tt>, and so on) performed for the library. These are all defined by the POM's <tt>packaging</tt> element.</p>
<p>Of course, the existing built-in commands are still available for building from Visual Studio, so development need not change day to day - but the build is there to be sure that the POM works as expected, so that you have the same build as other systems that will use it.</p>
<p>You may have noticed that there were other options that <i>Build</i> - namely <i>Test</i>, <i>Install</i> and <i>Clean</i>. There are other parts of what is known as the Maven <i>Build Lifecycle</i>.</p>
<div class="section"><h4>The Build Lifecycle</h4>
<p>Maven uses the POM to drive builds that a constructed as <i>patterns</i>. No matter what type of project you are building it can be shaped to Maven's build lifecycle, which is a sequence of phases always run in the same order, and for which a given phase can be sure that the previous phases have always executed as part of this build.</p>
<p>There are quite a number of phases that Maven plugins can participate, and that you can run from the <tt>mvn</tt> command, but the Visual Studio Add-in exposes the primary ones:</p>
<ul><li><tt>compile</tt> - compile source code into binary output</li>
<li><tt>test</tt> - run unit tests (such as NUnit) against the code to verify that the package will work</li>
<li><tt>install</tt> - produce the package and install it into Maven's <i>local repository</i>.</li>
</ul>
<p>What this means is that if you run <tt>mvn install</tt>, you will actually run compile, then test, then install (and the intermediate steps). Maven views testing as important, so this structure ensures that you run any unit tests you have before using the final DLL, for example. Running the <i>install</i> phase is the most common one used when building a project with Maven.</p>
<p>The installation phase is different to the traditional meaning of installing software. Maven maintains a <i>local repository</i> on the current machine (by default in <tt>%HOMEDRIVE%%HOMEPATH%\.m2\repository</tt>) where all build output is stored. This common storage allows sharing between different projects on the same machine when they express a dependency on another project. You have already encountered this when installing NPanday, as Maven uses the local repository to house it's own functionality as well.</p>
<p>We'll also learn later that Maven utilizes <i>remote repositories</i> to obtain dependencies from other sources, and to publish build output for sharing with other users. In this case, the local repository acts as a local intermediatary and cache between Maven and the remote repositories.</p>
<p>In addition to the above phase, there is the <i>Clean</i> option, which uses a different 'lifecycle' for cleaning up any build output such as the <tt>target</tt>, <tt>Bin</tt> and <tt>Obj</tt> directories.</p>
</div>
</div>
<div class="section"><h3>Summary</h3>
<p>In this simple example, we've seen how we can turn an existing .NET project into a functional Maven project, and learned some of the basic terminology and interactions with the new build system. In further parts of the guide, we will learn more about how Visual Studio and Maven interact through NPanday.</p>
<p>You can now read on about <a href="./references.html"> working with references</a>, or go back to the <a href="./index.html"> index</a>.</p>
</div>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2010
    
          NPanday
          
  

  
    
            
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
